package 网络编程;

import java.text.DateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

//日志类
public class Log {
    public static void println(Object o){
        LocalDateTime localDateTime =LocalDateTime.now(ZoneId.of("Asia/Shanghai"));//该类的构造方法私有，通过静态方法获取时间戳
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
        String time = format.format(localDateTime);
        //所以要打印的信息就是时间+对象信息
        System.out.println(time +" : "+ (o == null ? null : o.toString()));
    }

    public static void main(String[] args) {
        println(null);
    }
}
